import React from 'react';
import { Modal, Input, message } from 'antd';

interface AddSubDirModalProps {
  visible: boolean;
  onCancel: () => void;
  onOk: (name: string) => void;
}

const AddSubDirModal: React.FC<AddSubDirModalProps> = ({ visible, onCancel, onOk }) => {
  const [newSubDirName, setNewSubDirName] = React.useState('');

  const handleOk = () => {
    if (!newSubDirName.trim()) {
      message.warning('请输入目录名称');
      return;
    }
    onOk(newSubDirName);
    setNewSubDirName('');
  };

  return (
    <Modal
      title="添加子目录"
      open={visible}
      onOk={handleOk}
      onCancel={() => {
        onCancel();
        setNewSubDirName('');
      }}
      okText="确认"
      cancelText="取消"
    >
      <Input
        placeholder="请输入目录名称"
        value={newSubDirName}
        onChange={(e) => setNewSubDirName(e.target.value)}
        maxLength={20}
      />
    </Modal>
  );
};

export default AddSubDirModal; 